package com.maolong.springbootstartordercenter.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {

    /**
     * 配置消息队列
     * @return
     */
    @Bean
    public Queue payQueue(){return new Queue("payQueue",true);}
    @Bean
    public Queue storageQueue(){return new Queue("storageQueue",true);}

    /**
     * 配置Topic交换机
     * @return
     */
    @Bean
    public TopicExchange topicExchange(){return new TopicExchange("spring-topicExchange",true,false);}

    /**
     * 配置队列和交换机的绑定关系
     */
    @Bean
    public Binding bindingPayQueue(){return BindingBuilder.bind(payQueue()).to(topicExchange()).with("pay.#");}
    @Bean
    public Binding bindingStorageQueue(){return BindingBuilder.bind(storageQueue())
            .to(topicExchange())
            .with("storage.#");}

    //配置生产者
    //配置监听器
    //配置消息转换器
    //配置消息确认机制
    //配置死信队列
    //配置延迟队列
    //配置消息持久化
    //配置消息限流
    //配置消息重试
    //配置消息回退
    //配置消息追踪

}
